package com.app.shop.adapters;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.app.shop.R;
import com.app.shop.beans.ZHBean;
import com.app.library.utils.GlideUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;


public class ZHListAdapter extends BaseQuickAdapter<ZHBean, ZHListAdapter.ViewHolder> {

    int from;

    public ZHListAdapter(int layout, @Nullable List<ZHBean> data, int from) {
        super(layout, data);
        this.from = from;
    }

    public ZHListAdapter(int layout, @Nullable List<ZHBean> data) {
        super(layout, data);
    }


    @Override
    protected void convert(ViewHolder holder, ZHBean bean) {

        GlideUtils.getInstance().loadImage(mContext, bean.good_pic_path, holder.imgv_pic);
        holder.tv_name.setText("商品：" + bean.goods_name);
        holder.tv_remark.setText("类别：" + bean.goods_type);
        holder.tv_price.setText("价格：￥" + bean.goods_price);
        holder.tv_mobile.setText("");


        // // 1 置换中 2 拒绝  3 通过
        if (bean.zhihuan == 1) {
            holder.tv_status.setText("置换中");
        } else if (bean.zhihuan == 2) {
            holder.tv_status.setText("已拒绝");
        } else if (bean.zhihuan == 3) {
            holder.tv_status.setText("置换完成");
        }

        holder.tv_id.setText("编号：" + bean.z_id);
        GlideUtils.getInstance().loadImage(mContext, bean.zh_goods_pic, holder.imgv_list_zh);
        holder.tv_name_zh.setText("商品：" + bean.zh_goods_name);
        holder.tv_remark_zh.setText("类别：" + bean.zh_goods_type);
        holder.tv_price_zh.setText("价格：￥" + bean.zh_goods_price);
        holder.tv_mobile_zh.setText("");

        if (from == 2) {

            if (bean.zhihuan == 2 || bean.zhihuan == 3) {
                holder.ll_bt.setVisibility(View.GONE);
            } else {
                holder.ll_bt.setVisibility(View.VISIBLE);
            }
        } else {
            holder.ll_bt.setVisibility(View.GONE);
        }


        holder.addOnClickListener(R.id.tv_left).addOnClickListener(R.id.tv_right);
    }


    public class ViewHolder extends BaseViewHolder {
        ImageView imgv_pic;
        TextView tv_name;
        TextView tv_remark;
        TextView tv_price;
        TextView tv_status;
        TextView tv_mobile;

        TextView tv_id;


        ImageView imgv_list_zh;
        TextView tv_name_zh;
        TextView tv_remark_zh;
        TextView tv_price_zh;
        TextView tv_mobile_zh;

        LinearLayout ll_bt;
        TextView tv_left;
        TextView tv_right;


        public ViewHolder(View view) {
            super(view);
            imgv_pic = view.findViewById(R.id.imgv_list);
            tv_name = view.findViewById(R.id.tv_list_item);
            tv_remark = view.findViewById(R.id.tv_list_type);
            tv_price = view.findViewById(R.id.tv_price);
            tv_mobile = view.findViewById(R.id.tv_list_mobile);

            tv_id = view.findViewById(R.id.tv_id);
            tv_status = view.findViewById(R.id.tv_status);
            imgv_list_zh = view.findViewById(R.id.imgv_list_zh);
            tv_name_zh = view.findViewById(R.id.tv_list_item_zh);
            tv_remark_zh = view.findViewById(R.id.tv_list_type_zh);
            tv_price_zh = view.findViewById(R.id.tv_price_zh);
            tv_mobile_zh = view.findViewById(R.id.tv_list_mobile_zh);

            ll_bt = view.findViewById(R.id.ll_bt);
            tv_left = view.findViewById(R.id.tv_left);
            tv_right = view.findViewById(R.id.tv_right);
        }
    }
}
